package test00.lx05.test01;

import java.util.Arrays;
import java.util.function.Supplier;

/**
 * @author CSY
 * @date 2025 - 04 - 02
 */
public class MainTest01 {
    public static void main(String[] args) {
        Student[] stus = {
                new Student("张三",18),
                new Student("李四",16),
                new Student("王五",14),
                new Student("赵六",20),
                new Student("小七",21),
        };
        Supplier<Student> supplier = new Supplier<Student>() {
            @Override
            public Student get() {
                //默认最小值
                /*Student stu = stus[0];
                for (Student s : stus) {
                    if(stu.getAge() > s.getAge()){
                        stu = s;
                    }
                }*/
                Arrays.sort(stus, (o1, o2)->o2.getAge()-o1.getAge());
                return stus[stus.length-1];
            }
        };
        Student student = supplier.get();
        System.out.println(student.getName() + "-" + student.getAge());

    }
}
